﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="my" uri="/mytags"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>国家资助管理</title>
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/asserts/bootstrap-3.3.7-dist/css/bootstrap.min.css" />

<!-- js插件 -->
<script src="${pageContext.request.contextPath}/js/jquery-3.2.1.min.js"></script>
<script
	src="${pageContext.request.contextPath}/asserts/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/asserts/bootstrapValidate/css/bootstrapValidator.min.css" />
<script
	src="${pageContext.request.contextPath}/asserts/bootstrapValidate/js/bootstrapValidator.min.js"></script>
 <style type="text/css">
			button{
 				height:30px;
 				padding:2px;
 			}
 			.btn{
 				height:30px;
 				padding:2px;
 			}
 			.panel-body{
 				padding:2px;
 			}
 		    .form-group{
 		    	margin:1px;
 		    	padding:1px;
 		    }
 		      table tr th,table tr td{
 		    	text-align:center;
 		    }
	</style>
</head>
<body>
	<!-- 内容展示区 -->
	<div>
		<!-- 导航 -->
		<ol class="breadcrumb">
			<li><i class="fa fa-comment"></i> 国家资助管理</li>
		</ol>
		<div >
			<!-- 	内容面板 -->
			<div class="panel panel-default">
				<!-- 控制按钮 -->
				<div class="panel-heading">
					<div class="btn-group">
						<button class="btn btn-primary" onclick="addById()">
							<span class="glyphicon glyphicon-pencil"></span>添加
						</button>
						<button class="btn btn-success"  data-toggle="modal" data-target="#mymodalimport">
							<span class="glyphicon glyphicon-import"></span>导入excel
						</button>
						<button class="btn btn-info" onclick="downTemplate()">
							<span class="glyphicon glyphicon-export"></span>导出excel模板
						</button>
						<button class="btn btn-danger" onclick="removeAll()">
						<span class="glyphicon glyphicon-remove"></span>批量删除</button>
										
					</div>
					 	<form action="${pageContext.request.contextPath}/countrysub/list" method="post"  class="form-horizontal" >
							<div class="form-group"  style="margin-top:1px">
									<label class="control-label col-md-2">受助项目：</label>
									<div class="col-md-3">
										<select name="project" class="form-control" id="project">
											<option value="">请选择</option>
											<option value="学前教育资助" <c:if test="${project=='学前教育资助'}">selected="selected"</c:if>>学前教育资助</option>
											<option value="一补" <c:if test="${project=='一补'}">selected="selected"</c:if>>一补</option>
											<option value="普通高中国家助学金" <c:if test="${project=='普通高中国家助学金'}">selected="selected"</c:if>>普通高中国家助学金</option>
											<option value="普通高中免学杂费" <c:if test="${project=='普通高中免学杂费'}">selected="selected"</c:if>>普通高中免学杂费</option>
											<option value="中职国家助学金" <c:if test="${project=='中职国家助学金'}">selected="selected"</c:if>>中职国家助学金</option>
											<option value="中职免学费" <c:if test="${project=='中职免学费'}">selected="selected"</c:if>>中职免学费</option>
											<option value="城市低保非寄宿生县级资助" <c:if test="${project=='城市低保非寄宿生县级资助'}">selected="selected"</c:if>>城市低保非寄宿生县级资助</option>
											<option value="城市低保高中免学费" <c:if test="${project=='城市低保高中免学费'}">selected="selected"</c:if>>城市低保高中免学费</option>
											<option value="精准扶贫高中复读学生免学费" <c:if test="${project=='精准扶贫高中复读学生免学费'}">selected="selected"</c:if>>精准扶贫高中复读学生免学费</option>
											<option value="精准扶贫高中复读学生助学金" <c:if test="${project=='精准扶贫高中复读学生助学金'}">selected="selected"</c:if>>精准扶贫高中复读学生助学金</option>
											<option value="因疫致贫困学生资助" <c:if test="${project=='因疫致贫困学生资助'}">selected="selected"</c:if>>因疫致贫困学生资助</option>
											 <option value="大学新生入学资助" <c:if test="${project=='大学新生入学资助'}">selected="selected"</c:if>>大学新生入学资助</option>
											 <option value="普通高中滋蕙计划" <c:if test="${project=='普通高中滋蕙计划'}">selected="selected"</c:if>>普通高中滋蕙计划</option>
									 
								 
										</select>
									</div>
								   <%--  <label class="control-label col-md-2">所在学校：</label>
										<div class="col-md-3">
											 <select name="schid" class="form-control">
												<option value="">请选择</option>
											 	<c:forEach var="school" items="${schoolList}">
											 		<option value="${school.schid}" <c:if test="${school.schid==schid}">selected="selected"</c:if>>${school.name}(${school.level})</option>
											 		
											 	</c:forEach>
												</select> 
										</div> --%>
								 
							
							</div>
						 
							<div class="form-group" >
								<label class="control-label  col-md-2">学生姓名：</label>
								<div class="col-md-3">
									<input type="text" name="name" value="${name}" id="selectName"
										placeholder="输入学生姓名" class="form-control" />
								</div>
								<label class="control-label  col-md-2">身份证号：</label>
								<div class="col-md-3">
									<input type="text" name="idcard" value="${idcard}" id="selectIdCard"
										placeholder="输入身份证号码" class="form-control" />
								</div>
								
		
							</div>
							 <div class="form-group"  >
									 	 <label class="control-label col-md-2">所属乡镇：</label>
											<div class="col-md-3">
												 		  <select id="zid" name="zid" class="form-control" onchange="changeZhen(this)">
															<option value="">请选择</option>
															<c:forEach var="xz" items="${xzList}">
																<option value="${xz.id}" <c:if test="${xz.id==zid}">selected="selected"</c:if>>${xz.name}</option>
															</c:forEach>
														</select>
											</div>
										<label class="control-label col-md-2">所属学校(先选择乡镇)：</label>
										<div class="col-md-3">
											 <select id="schid" name="schid" class="form-control">
												<option value="">请选择</option>
												  <c:forEach var="school" items="${schoolListByZid}">
										 		   <option value="${school.schid}" <c:if test="${school.schid==schid}">selected="selected"</c:if>>${school.name}(${school.level})</option>
										 		
										 	      </c:forEach>
											</select> 
										</div>
										<div class="col-md-2  form-group">
											<button class="btn btn-success"  type="submit">查询</button>
										</div>
									</div>
									 
					</form>
					</div>
					<!-- 控制按钮  end-->
					<div class="panel-body">
						<table class="table table-bordered table-striped table-condensed table-hover" id="listtable">
							<tr class="success">
								
								<th width="42%" colspan="7" style="text-align: center">受助学生信息</th>
								<th width="15%" colspan="2" style="text-align: center">受助原因</th>
								<th width="5%">家长</th>
								<!-- 家长(监护人)信息 -->
								<th width="10%" colspan="2" style="text-align: center">账户信息</th>
								<th  width="7%" style="text-align: center">状态</th>
								<th width="30%" rowspan="2" style="text-align: center">操作</th>
							</tr>
							<tr class="success">
								<th width="2%" ><input type="checkbox" id="selectAll" onclick="checkAlls(this)" /></th>
								<th  width="2%"  style="text-align: center">序号</th>
								<th width="6%">姓名</th>
								<th width="3%">性别</th>
								<th width="5%">年级</th>
								<th width="7%">班级</th>
								<th width="10%">身份证号</th>
								<th style="display:none" width="10%">学籍号</th>
								<th width="10%">受助类别</th>
								<th width="10%">详细原因</th>
								<th width="6%">家长</th>
								<!-- 家长姓名 -->
								<!-- <th width="5%">与学生关系</th>
								<th width="10%">联系电话</th> -->
								<th width="5%">银行卡或存折号</th>
								<th width="5%"><span title="资助金额或免学费金额">资助金额..</span><th>
								 
							</tr>
							<c:forEach items="${pageInfo.list}" var="CountrySub" varStatus="vs">
								<tr <c:if test="${CountrySub.applyfile==null}">style="color:red"</c:if>>
								    <td><input type="checkbox" name="checkId" value="${CountrySub.id}-${CountrySub.status}" /></td>
								 	<td width="4%" style="text-align:center" >${(pageInfo.pageNum-1)*20+vs.count}</td>
									<td style="display:none" width="3%">${CountrySub.id}</td>
									<td width="5%">${CountrySub.name}</td>
									<td width="5%">${CountrySub.sex}</td>
									<td width="5%">${CountrySub.grade}</td>
									<td width="7%">${CountrySub.classes}</td>
									<td width="10%">${CountrySub.idcard}</td>
									<td style="display:none" width="10%">${CountrySub.stucode}</td>
									<td width="10%">${CountrySub.type}</td>
									<td width="10%">
										<c:if test="${fn:length(CountrySub.descinfo)>5}">
										<span title="${CountrySub.descinfo}">${fn:substring(CountrySub.descinfo,0,5)}...</span>	
										</c:if>
										<c:if test="${fn:length(CountrySub.descinfo)<=5}">
											${CountrySub.descinfo}
										</c:if>
									</td>
									<td width="5%">${CountrySub.parentname}</td>
									<%-- <th width="10%">${CountrySub.relation}</th>
									<th width="10%">${CountrySub.phone}</th> --%>
									<td width="5%">${CountrySub.bankno}</td>
									<td width="5%">${CountrySub.amount}</td>
									<td>
												<c:if test="${CountrySub.status==1}">初稿</c:if>
												<c:if test="${CountrySub.status==2}">镇审核中</c:if>
												<c:if test="${CountrySub.status==3}">县审核中</c:if>
<%-- 											<c:if test="${dataup.status==4}">归档</c:if>
 --%>								</td>
									<td>
										<button type="button" class="btn btn-primary" 
											onclick="updateBy(${CountrySub.id},${CountrySub.status})">
											<span class="glyphicon glyphicon-edit"></span> 修改
										</button>
										<button type="button" class="btn btn-danger"  
											onclick="del(${CountrySub.id},${CountrySub.status})">
											<span class="glyphicon glyphicon-remove"></span> 删除
										</button>
										<a class="btn btn-info"  href="selectById?id=${CountrySub.id}" target="_blank">
																	
										<span class="glyphicon glyphicon-list"></span>详情</a>
										<c:if test="${CountrySub.status==1}">			
																				<button type="button" class="btn btn-success" style="width:100px"
																					data-toggle="modal" data-target="#mymodal" onclick="uploadImg(${CountrySub.id},${CountrySub.status})">
																					<span class="glyphicon glyphicon-upload"></span>上传扫描件
																				</button>
										</c:if>
									</td>
								</tr>

							</c:forEach>

						</table>

						<!-- 	分页 -->
						<my:page prePage="${pageInfo.prePage}"
							nextPage="${pageInfo.nextPage}"
							url="${pageContext.request.contextPath}/countrysub/list?n=1&x=1"
							totalPage="${pageInfo.pages}" currentPage="${pageInfo.pageNum}" />

						<!-- 	分页 -->
						<!-- <nav class="text-center">
							<ul class="pagination pagination-sm" id="pageNumber">
								<li class="disabled"><a href="javascript:void(0)">&laquo;</a></li>

								<li><a href="">&raquo;</a></li>
							</ul>
						</nav> -->
					</div>
				</div>
				<!-- 内容面板 end -->
			</div>
		</div>
		<!-- 	内容展示区 end-->


		<!-- 弹层组件 添加标签 -->
		<div class="modal fade" id="mymodal">
			<div class="modal-dialog">
				<div class="modal-content">
					<form action="${pageContext.request.contextPath}/countrysub/updateByImg"
					method="post"
					enctype="multipart/form-data"  class="form-horizontal">
						<!-- 隐藏域带入idcard -->
						<input type="hidden" name="id" id="id"  class="form-control" />

						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal">
								<span>&times;</span>
							</button>
							<h4 class="modal-title" id="mylabel">
								<span class="glyphicon glyphicon-upload"></span> 上传扫描件
							</h4>
						</div>
						<div class="modal-body">
							<!-- 学校-->
							<div class="form-group">
								<label class="control-label col-md-3">申请表缩略图：</label>
								<div class="col-md-8">
									<input type="file" name="applyfile" />
								</div>
							</div>
							<!-- 学校-->
							<div class="form-group">
								<label class="control-label col-md-3">认定表缩略图：</label>
								<div class="col-md-8">
									<input type="file" name="apply2file" />
								</div>
							</div>
							<div class="form-group">
								<label class="control-label col-md-3">其他家庭经济情况佐证材料缩略图：</label>
								<div class="col-md-8">
									<input type="file" name="apply3file" />
								</div>
							</div>

							<div class="form-group">
								<label class="control-label col-md-3">学生身份证正面缩略图：</label>
								<div class="col-md-8">
									<input type="file" name="idcardfile" />
								</div>
							</div>
							<div class="form-group">
								<label class="control-label col-md-3">学生身份证反面缩略图：</label>
								<div class="col-md-8">
									<input type="file" name="idcard2file" />
								</div>
							</div>
							<div class="form-group">
								<label class="control-label col-md-3">学生户口页缩略图：</label>
								<div class="col-md-8">
									<input type="file" name="stufile" />
								</div>
							</div>
							<div class="form-group">
								<label class="control-label col-md-3">学生家庭户口簿家庭成员页缩略图：</label>
								<div class="col-md-8">
									<input type="file" name="addressfile" />
								</div>
							</div>
							<div class="form-group">
								<label class="control-label col-md-3">家长或监护人户口页缩略图：</label>
								<div class="col-md-8">
									<input type="file" name="address2file" />
								</div>
							</div>
							<div class="form-group">
								<label class="control-label col-md-3">银行卡或存折缩略图：</label>
								<div class="col-md-8">
									<input type="file" name="bankfile" />
								</div>
							</div>
						</div>
						<div class="modal-footer">
							<button class="btn btn-danger"  data-dismiss="modal" type="button">关闭</button>
							<button class="btn btn-primary" type="submit">确认上传</button>
						</div>
					</form>
				</div>
			</div>
		</div>
		
		
<div class="modal fade" id="mymodalimport">
			<div class="modal-dialog">
				<div class="modal-content">
					<form action="${pageContext.request.contextPath}/countrysub/importBetch"
					method="post" enctype="multipart/form-data"  class="form-horizontal">
						<div class="modal-header">  
							<button type="button" class="close" data-dismiss="modal"><span>&times;</span></button>
							<h4 class="modal-title" id="mylabel">导入国家资助学生信息</h4>
 						</div>
						<div class="modal-body">
							   
							  <!-- 学校-->
								<div class="form-group">
									<label class="control-label col-md-3">选择导入的文件（excel格式）：</label>
									<div class="col-md-8">
									    <input type="file"  name="file" class="form-control"  />
									</div>
								</div>
								  <!-- 学校-->
							 
						</div>
						<div class="modal-footer">
							<button class="btn btn-danger" data-dismiss="modal" type="button">关闭</button>
							<button class="btn btn-primary" type="submit" >导入</button>
						</div>
					</form>
				</div>
			</div>
		</div><!-- 弹层组件 添加标签 end -->
		
		
</body>
<script type="text/javascript">
document.documentElement.style.overflowY = 'hidden'; 

function changeZhen(obj){
	 //ajax   根据镇id 查询 它学校表中的 数据 
	if(obj.value!=''){
		  $.ajax({
				url : '../school/getSchoolByZid?zid='+obj.value,
				type : "get",
				dataType : "json",
				success : function(data) {
					 
					if(data!=null){
						$("#schid option:gt(0)").remove();
						for(var i=0;i<data.length;i++){
							var opt = "<option value='"+data[i].schid+"'>"+data[i].name+"("+data[i].level+")</optoin>";
							$("#schid").append(opt);
						}
					} 
				},
				error : function(xhr) {
					 
				}
			});
	}else{
		$("#schid option:gt(0)").remove();
	}
}


	function addById() {
		location.href = "addBy";
	}
	
	function del(id,status){
		if(status!=1){
			alert("该学生已审批，不能删除");
			return;
		}
	  	var flag =  confirm("确认是否删除？");
	  	if(flag){
	  		var path  ='${pageContext.request.contextPath}';
	  		//alert(id);
	  		location.href= path+"/countrysub/deleteById?id="+id;
	  	}
	}
	
	function updateBy(id,status){
		if(status!=1){
			alert("该学生已审批，不能再次修改");
			return;
		}
	  	location.href= "updateBySelectCountrySub?id="+id;
	}
	
	function selectBy(id){
	  	location.href= "selectById?id="+id;
	}
	
	
	  
	   function downTemplate(){
		 
		   location.href="downTemplate";
	   }
		 
	   $('form').bootstrapValidator({
		   
	　　　　　　　message: 'This value is not valid',
	            	　feedbackIcons: {
	                　　　　　　　　valid: 'glyphicon glyphicon-ok',
	                　　　　　　　　invalid: 'glyphicon glyphicon-remove',
	                　　　　　　　　validating: 'glyphicon glyphicon-refresh'
	            　　　　　　　　   },
	            fields: {
	            	applyfile: {
	                    message: '用户名验证失败',
	                    validators: {
	                        notEmpty: {
	                            message: '申请表缩略图不能为空'
	                        }
	                    }
	                },
	                apply2file: {
	                    message: '用户名验证失败',
	                    validators: {
	                        notEmpty: {
	                            message: '认定表缩略图不能为空'
	                        }
	                    }
	                } ,
	                apply3file: {
	                    message: '用户名验证失败',
	                    validators: {
	                        notEmpty: {
	                            message: '作证材料缩略图不能为空'
	                        }
	                    }
	                } ,
	                idcardfile: {
	                    message: '用户名验证失败',
	                    validators: {
	                        notEmpty: {
	                            message: '学生身份证正面缩略图不能为空'
	                        }
	                    }
	                } ,
	                idcard2file: {
	                    message: '用户名验证失败',
	                    validators: {
	                        notEmpty: {
	                            message: '学生身份证反面缩略图不能为空'
	                        }
	                    }
	                } ,
	                stufile: {
	                    message: '用户名验证失败',
	                    validators: {
	                        notEmpty: {
	                            message: '学生户口页缩略图不能为空'
	                        }
	                    }
	                } ,
	                addressfile: {
	                    message: '用户名验证失败',
	                    validators: {
	                        notEmpty: {
	                            message: '学生家庭户口簿家庭成员页缩略图不能为空'
	                        }
	                    }
	                } ,
	                address2file: {
	                    message: '用户名验证失败',
	                    validators: {
	                        notEmpty: {
	                            message: '家长或监护人户口页缩略图不能为空'
	                        }
	                    }
	                } ,
	                bankfile: {
	                    message: '用户名验证失败',
	                    validators: {
	                        notEmpty: {
	                            message: '银行卡或存折缩略图不能为空'
	                        }
	                    }
	                }
	            } ,
	            submitHandler: function (validator, form, submitButton) {
	              // alert("submit");
	            }
	        });
	 
		 
	          
	          function uploadImg(id,status){
	        	  if(status!=1){
	        		  alert("该学生已通过审批，不能变更档案！");
	        		  return ;
	        	  }
	        	    $("#id").val(id);
	          }
	          //批量删除 
	    	  function removeAll(){
	        	  var msg="";
	    		 var ids="";
	    			var checkId= document.getElementsByName("checkId");
	    			 for(var i=0;i<checkId.length;i++){
	    				 if(checkId[i].checked==true){
	    					 //获取id  和 状态  ，只有状态为1 可以删除
	    					  var s =checkId[i].value;
	    					 var id = s.substring(0,s.indexOf("-"));
	    					 var status = s.substring(s.indexOf("-")+1);
	    					 if(status!="1"){
	    						// alert("只能删除草稿状态的学生。 ");
	    						// return;   获取序号
	    						msg+="["+$(checkId[i]).parent().next().text()+"]";
	    					 }
	    					 ids+=id+",";
	    				 }
	    			 }
	    			 
	    			 //验证所有的状态是否为草稿 
	    			 if(msg!=""){
	    				 alert("只能删除初稿状态的学生， 序号 "+msg+"的数据不能删除。 ");
	    				 return;
	    			 }
	    			 
	    		    ids=ids.substring(0,ids.length-1);
	    		    var flag =  confirm("确认是否批量删除，请再次核实数据？");
	    		  	   if(flag){
	    		  		   var path  ='${pageContext.request.contextPath}';
	    		  		   //alert(id);
	    		  		    location.href= path+"/countrysub/deleteBatch?ids="+ids;
	    		  	   }
	    	  }
	    	 
	    	 function checkAlls(obj){
	    		 var c = obj.checked;
	    		var checkId= document.getElementsByName("checkId");
	    		 for(var i=0;i<checkId.length;i++){
	    			 
	    			 checkId[i].checked=c;
	    		 }
	    		 
	    	 }
	    
	    	 $(function(){
	    		 var flag  ='${successFlag}';
	    		 if(flag=='true'){
	    			 alert('操作成功！ ');
	    		 }
	    			 
	    	 });
</script>

</html>
